package com.usfuture
{
	import flash.display.Sprite;

	public class Canvas extends Sprite implements ICanvas
	{
		private var _width:Number;
		private var _height:Number;
		private var _backgroundColor:uint;
		private var _alpha:Number;
		
		public function Canvas(width:Number, 
							   height:Number, 
							   backgroundColor:uint=0xFFFFFF,
							   alpha:Number=0)
		{
			super();
			this._width = width;
			this._height = height;
			this._backgroundColor = backgroundColor;
			this._alpha = alpha;
			updateDisplayList(width, height);
		}



		public function updateDisplayList(width:Number, height:Number):void
		{
			this.graphics.beginFill(_backgroundColor,alpha);
			this.graphics.drawRect(0,0,width,height);
			this.graphics.endFill();	
		}
		
		
		override public function get height():Number
		{
			return _height;
		}
		
		override public function set height(value:Number):void
		{
			_height = value;
			updateDisplayList(width, height);
		}
		
		override public function get width():Number
		{
			return _width;
		}
		
		override public function set width(value:Number):void
		{
			_width = value;
			updateDisplayList(width, height);
		}
		
		override public function get alpha():Number
		{
			return _alpha;
		}
		
		override public function set alpha(value:Number):void
		{
			_alpha = value;
			updateDisplayList(width, height);
		}
		
		public function get backgroundColor():uint
		{
			return _backgroundColor;
		}
		
		public function set backgroundColor(value:uint):void
		{
			_backgroundColor = value;
			updateDisplayList(width, height);
		}
	}
}